<?php
/**
 * Created by PhpStorm.
 * User: xx
 * Date: 15-05-28
 * Time: 14:47
 */
//require_once('myThumbClass.php');
define('UPLOAD_DIR', 'images/');
$img = $_POST['img'];

$img = str_replace('data:image/png;base64,', '', $img);
$img = str_replace('data:image/jpeg;base64,', '', $img);
$img = str_replace(' ', '+', $img);
$data = base64_decode($img);
$file = UPLOAD_DIR . uniqid() . '.png';
//$file_thumb = UPLOAD_DIR . uniqid() . '_thumb.jpg';
$success = file_put_contents($file, $data);
//$resizeimage = new myThumbClass($file, 80, 80, $file_thumb, 0, 0);
echo $success ? $file : '';
?>